package com.ruoyi.web.pojo.dto.devicedata;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @desc  风向频率统计
 * @author fwx 2024/3/1 15:25
 **/
@Data
public class PropertyWindCount {

    @ApiModelProperty(value = "东风次数")
    private Long eastRate = 0L;

    @ApiModelProperty(value = "南风次数")
    private Long southRate = 0L;

    @ApiModelProperty(value = "西风次数")
    private Long westRate = 0L;

    @ApiModelProperty(value = "北风次数")
    private Long northRate = 0L;

    @ApiModelProperty(value = "东南风次数")
    private Long southeastRate = 0L;

    @ApiModelProperty(value = "西南风次数")
    private Long southwestRate = 0L;

    @ApiModelProperty(value = "东北风次数")
    private Long northeastRate = 0L;

    @ApiModelProperty(value = "西北风次数")
    private Long northwestRate = 0L;

    public void countRate(Double wdir){
        if(wdir == null || wdir == 0){
            return;
        }

        if ( wdir >= 22 && wdir <= 67){
            //wdirStr = "东北";
            northeastRate++;
        } else if ( wdir > 67 && wdir <= 112) {
            // wdirStr = "东";
            eastRate++;
        } else if (wdir > 112 && wdir <= 157) {
            //wdirStr = "东南";
            southeastRate++;
        } else if (wdir > 157 && wdir <= 202) {
            //wdirStr = "南";
            southRate++;
        } else if (wdir > 202 && wdir <= 247) {
            //wdirStr = "西南";
            southwestRate++;
        } else if (wdir > 247 && wdir <= 292) {
            //wdirStr = "西";
            westRate++;
        } else if (wdir > 292 && wdir <= 337) {
            //wdirStr = "西北";
            northwestRate++;
        } else {
            //北
            northRate++;
        }
    }
    public String getWdirStr(Double wdir){
        String wdirStr = "北";
        if(wdir == null){
            return null;
        }

        if ( wdir >= 23 && wdir <= 67){
            wdirStr = "东北";
        } else if ( wdir >= 68 && wdir <= 112) {
            wdirStr = "东";
        } else if (wdir >= 113 && wdir <= 157) {
            wdirStr = "东南";
        } else if (wdir >= 158 && wdir <= 202) {
            wdirStr = "南";
        } else if (wdir >= 203 && wdir <= 247) {
            wdirStr = "西南";
        } else if (wdir >= 248 && wdir <= 292) {
            wdirStr = "西";
        } else if (wdir >= 293 && wdir <= 337) {
            wdirStr = "西北";
        } else {

        }
        return wdirStr;
    }

}
